import Vue from 'vue';
import VueRouter from 'vue-router';

let routes = [
  {
    path: '/',
    redirect: '/login',
  },
  {
    path: '/login',
    component: () => import('@/views/login.vue'),
  },
  {
    path: '/layout',
    component: () => import('@/views/layout.vue'),
    redirect: '/layout/index',
    children: [
      { path: 'index', component: () => import('@/views/index.vue') },
      { path: 'user', component: () => import('@/views/user.vue') },
      { path: 'columnlist', component: () => import('@/views/columnlist.vue') },
      {
        path: 'animallist',
        component: () => import('@/views/animallist.vue'),
      },
      { path: 'addanimal', component: () => import('@/views/addanimal.vue') },
    ],
  },
];
Vue.use(VueRouter);

let router = new VueRouter({
  routes,
});

const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch((err) => err);
};

export default router;
